package com.derbysoft.ota.interfaces.ws.hotel;

import com.derbysoft.ota.application.service.HotelAvailService;
import com.derbysoft.ota.application.service.StagingService;
import com.derbysoft.ota.domain.server.ServerType;
import com.derbysoft.ota.interfaces.protocol._2009a.OTAHotelAvailRQ;
import com.derbysoft.ota.interfaces.ws.AbstractEndpoint;

public class HotelAvailEndpoint extends AbstractEndpoint {

	private HotelAvailService hotelAvailService;
	
	public HotelAvailEndpoint(ServerType serverType, StagingService stagingService, HotelAvailService hotelAvailService) {
		super(serverType, stagingService);
		this.hotelAvailService = hotelAvailService;
	}

	@Override
	protected Object invokeInternal(Object requestObject) throws Exception {
		OTAHotelAvailRQ availRQ = (OTAHotelAvailRQ) requestObject;
		if (serverType.isStaging()) {
			return stagingService.getAvail(availRQ);
		}
		return hotelAvailService.get(availRQ);
	}

}
